package com.ktkq.action;

import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import org.apache.struts2.ServletActionContext;

@SuppressWarnings("serial")
public class DownloadAction extends BaseAction{

	   private String fileName;
	   private String filePath;
	   private String fileLength;

       public void setFileName(String fileName) {
               this.fileName = fileName;
       }
       public InputStream getExcelStream() {
    	         return ServletActionContext.getServletContext().getResourceAsStream("/"+filePath +"/"+ fileName);
       }      
       public String execute(){
               return SUCCESS;
       }
	public String getFileName() {
		try { 
			fileName = new String(fileName.getBytes(), "ISO8859-1");
			} catch (UnsupportedEncodingException e) {  
				
		}
		return fileName;
	}
	public String getFilePath() {
		return filePath;
	}
	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}
	public String getFileLength() {
		try {
		fileLength = ""+ServletActionContext.getServletContext().getResourceAsStream("/"+filePath +"/"+ fileName).available();
		
			return fileLength;
		} catch (IOException e) {
		
		}
	    return fileLength;   
	}
	public void setFileLength(String fileLength) {
		this.fileLength = fileLength;
	}
	
       
}
